<extend name="Base/ucenter" />
<block name="body">
    <form action="{:U('do_submit')}" method="post" class="ajax-form">
        <div class="form-row">
            <div class="form-l">
                <div><b>标题</b></div>
                <p class="warming">(必填)</p>
            </div>
            <div class="form-content">
                <input type="text" name="title" data-rules="{maxlen:20,required : true}" placeholder="请输入标题">
            </div>
        </div>
        <div class="form-row">
            <div class="form-l">
                <div><b>缩略图</b></div>
                <p class="warming">(必填)</p>
            </div>
            <div class="form-content">
                <input type="file" name="download" data-title="上传图片" accept=".jpeg,.jpg,.png" class="fileupload imgUpload" data-rules="{required : true}" data-key="thumb" data-value="{$thumb}">
            </div>
        </div>
        <div class="form-row">
            <div class="form-l">
                <div><b>视频文件</b></div>
                <p class="warming">(必填)</p>
            </div>
            <div class="form-content">
                <input type="file" class="fileupload videoUpload" data-title="上传视频" name="download" accept=".mp4" data-key="uri">
            </div>
        </div>
        <div class="form-row">
            <div class="form-l">
                <div><b>预览视频</b></div>
                <p class="warming"></p>
            </div>
            <div class="form-content">
                <input type="file" class="fileupload videoPreUpload" data-title="上传视频" name="download" accept=".mp4" data-key="pre_uri">
            </div>
        </div>
        <div class="form-row">
            <div class="form-l">
                <div><b>视频长度</b></div>
                <p class="warming">(必填)</p>
            </div>
            <div class="form-content">
                <input type="text" data-rules="{type : 'number', required : true,maxlen:3}" name="time" placeholder="视频长度">(数字 秒)
            </div>
        </div>
        <div class="form-row">
            <div class="form-l">
                <div><b>描述</b></div>
                <p>(限制50字)</p>
            </div>
            <div class="form-content">
                <textarea data-rules="{maxlen : 50}" name="detail"></textarea>
            </div>
        </div>
        <div class="form-row">
            <div class="form-l">
                <div><b>标签</b></div>
                <p></p>
            </div>
            <div class="form-content">
                <div class="search-tag" data-key="tags">
                    <input type="text">
                </div>
            </div>
        </div>
        <div class="submit-bar">
            {__TOKEN__}
            <input type="hidden" name="game_id" value="{$game.id}">
            <button class="btn JS_submit">提交</button>
            <a class="btn" href="{:U('choose_game')}">返回</a>
        </div>
    </form>
</block>
<block name="script">
    <script type="text/javascript">
    $(function() {
        var url = "{:U('Api/Tag/search')}";
        tagInit(url);
        $('.imgUpload').upload({
            uploader: "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
            staticPath: "{:C('PICTURE_UPLOAD.uri_path')}",
            //staticPath: "__ROOT__"
        });
        $('.videoUpload').upload({
            uploader: "{:U('File/uploadVideo',array('session_id'=>session_id()))}",
            staticPath: "{:C('VIDEO_UPLOAD.uri_path')}",
            type: 'video',
            success: function(data) {
                if (data.status == 0) {
                    alert(data.info);
                }
            }
        });
        $('.videoPreUpload').upload({
            uploader: "{:U('File/uploadVideo',array('session_id'=>session_id()))}",
            staticPath: "{:C('VIDEO_UPLOAD.uri_path')}",
            type: 'video'
        });
    })
    </script>
</block>